package demo;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Demo01 {
    public static void main(String[] args) {
        Date date = new Date();

        String year=String.format("%tY",date);
        System.out.println(year);
        String month=String.format("%tm",date);
        System.out.println(month);
        String month2=String.format("%tb",date);
        System.out.println(month2);

        String day=String.format("%te",date);
        System.out.println(day);
        String s=String.format("%td",date);
        System.out.println(s);

        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat formatter2 = new SimpleDateFormat();
        String s2= formatter2.format(date);
        System.out.println(s2);

        String s1 = formatter.format(date);
        System.out.println(s1);
        String[] arr2 = s1.split("-");
        int year2=Integer.parseInt(arr2[0]);
    }
}
